#pragma once

#include "Typedef.h"
//////////////////////////////////////////////////////////////////////////////////

// 聊天规则
#define SR_FORBID_GAME_CHAT 0x00000001      // 禁止公聊
#define SR_FORBID_ROOM_CHAT 0x00000002      // 禁止公聊
#define SR_FORBID_WISPER_CHAT 0x00000004    // 禁止私聊
#define SR_FORBID_WISPER_ON_GAME 0x00000008 // 禁止私聊

// 高级规则
#define SR_ALLOW_DYNAMIC_JOIN 0x00000010     // 动态加入
#define SR_ALLOW_OFFLINE_TRUSTEE 0x00000020  // 断线代打
#define SR_ALLOW_AVERT_CHEAT_MODE 0x00000040 // 隐藏信息

// 游戏规则
#define SR_RECORD_GAME_SCORE 0x00000100     // 记录积分
#define SR_RECORD_GAME_TRACK 0x00000200     // 记录过程
#define SR_DYNAMIC_CELL_SCORE 0x00000400    // 动态底分
#define SR_IMMEDIATE_WRITE_SCORE 0x00000800 // 即时写分

// 房间规则
#define SR_FORBID_ROOM_ENTER 0x00001000  // 禁止进入
#define SR_FORBID_GAME_ENTER 0x00002000  // 禁止进入
#define SR_FORBID_GAME_ONLOOK 0x00004000 // 禁止旁观

// 银行规则
#define SR_FORBID_TAKE_IN_ROOM 0x00010000 // 禁止取款
#define SR_FORBID_TAKE_IN_GAME 0x00020000 // 禁止取款
#define SR_FORBID_SAVE_IN_ROOM 0x00040000 // 禁止存钱
#define SR_FORBID_SAVE_IN_GAME 0x00080000 // 禁止存款

// 其他规则
#define SR_FORBID_GAME_RULE 0x00100000       // 禁止配置
#define SR_FORBID_LOCK_TABLE 0x00200000      // 禁止锁桌
#define SR_ALLOW_ANDROID_ATTEND 0x00400000   // 允许陪玩
#define SR_ALLOW_ANDROID_SIMULATE 0x00800000 // 允许占位

// 支持规则
#define SR_SUPPORT_TYPE_PC 0x01000000     // 支持PC
#define SR_SUPPORT_TYPE_MOBILE 0x02000000 // 支持手机
#define SR_SUPPORT_PLAY_BACK 0x04000000   // 支持回放

//////////////////////////////////////////////////////////////////////////////////

// 房间规则
class CServerRule {
  // 聊天规则
public:
  // 禁止公聊
  static bool IsForbidGameChat(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_GAME_CHAT) != 0; }
  // 禁止公聊
  static bool IsForbidRoomChat(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_ROOM_CHAT) != 0; }
  // 禁止私聊
  static bool IsForbidWisperChat(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_WISPER_CHAT) != 0; }
  // 禁止私聊
  static bool IsForbidWisperOnGame(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_WISPER_ON_GAME) != 0; }

  // 模式规则
public:
  // 动态加入
  static bool IsAllowDynamicJoin(DWORD dwServerRule) { return (dwServerRule & SR_ALLOW_DYNAMIC_JOIN) != 0; }
  // 断线代打
  static bool IsAllowOffLineTrustee(DWORD dwServerRule) { return (dwServerRule & SR_ALLOW_OFFLINE_TRUSTEE) != 0; }
  // 隐藏信息
  static bool IsAllowAvertCheatMode(DWORD dwServerRule) { return (dwServerRule & SR_ALLOW_AVERT_CHEAT_MODE) != 0; }

  // 游戏规则
public:
  // 记录积分
  static bool IsRecordGameScore(DWORD dwServerRule) { return (dwServerRule & SR_RECORD_GAME_SCORE) != 0; }
  // 记录过程
  static bool IsRecordGameTrack(DWORD dwServerRule) { return (dwServerRule & SR_RECORD_GAME_TRACK) != 0; }
  // 动态底分
  static bool IsDynamicCellScore(DWORD dwServerRule) { return (dwServerRule & SR_DYNAMIC_CELL_SCORE) != 0; }
  // 即时写分
  static bool IsImmediateWriteScore(DWORD dwServerRule) { return (dwServerRule & SR_IMMEDIATE_WRITE_SCORE) != 0; }

  // 房间规则
public:
  // 禁止进入
  static bool IsForbidRoomEnter(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_ROOM_ENTER) != 0; }
  // 禁止进入
  static bool IsForbidGameEnter(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_GAME_ENTER) != 0; }
  // 禁止旁观
  static bool IsForbidGameOnlook(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_GAME_ONLOOK) != 0; }

  // 银行规则
public:
  // 禁止取款
  static bool IsForbidTakeInRoom(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_TAKE_IN_ROOM) != 0; }
  // 禁止取款
  static bool IsForbidTakeInGame(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_TAKE_IN_GAME) != 0; }
  // 禁止存钱
  static bool IsForbidSaveInRoom(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_SAVE_IN_ROOM) != 0; }
  // 禁止存钱
  static bool IsForbidSaveInGame(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_SAVE_IN_GAME) != 0; }

  // 其他规则
public:
  // 禁止配置
  static bool IsForbidGameRule(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_GAME_RULE) != 0; }
  // 禁止锁桌
  static bool IsForbidLockTable(DWORD dwServerRule) { return (dwServerRule & SR_FORBID_LOCK_TABLE) != 0; }
  // 允许陪玩
  static bool IsAllowAndroidAttend(DWORD dwServerRule) { return (dwServerRule & SR_ALLOW_ANDROID_ATTEND) != 0; }
  // 允许占位
  static bool IsAllowAndroidSimulate(DWORD dwServerRule) { return (dwServerRule & SR_ALLOW_ANDROID_SIMULATE) != 0; }

  // 聊天规则
public:
  // 禁止公聊
  static VOID SetForbidGameChat(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_GAME_CHAT : dwServerRule &= ~SR_FORBID_GAME_CHAT;
  }
  // 禁止公聊
  static VOID SetForbidRoomChat(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_ROOM_CHAT : dwServerRule &= ~SR_FORBID_ROOM_CHAT;
  }
  // 禁止私聊
  static VOID SetForbidWisperChat(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_WISPER_CHAT : dwServerRule &= ~SR_FORBID_WISPER_CHAT;
  }
  // 禁止私聊
  static VOID SetForbidWisperOnGame(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_WISPER_ON_GAME : dwServerRule &= ~SR_FORBID_WISPER_ON_GAME;
  }

  // 模式规则
public:
  // 动态加入
  static VOID SetAllowDynamicJoin(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_ALLOW_DYNAMIC_JOIN : dwServerRule &= ~SR_ALLOW_DYNAMIC_JOIN;
  }
  // 断线代打
  static VOID SetAllowOffLineTrustee(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_ALLOW_OFFLINE_TRUSTEE : dwServerRule &= ~SR_ALLOW_OFFLINE_TRUSTEE;
  }
  // 隐藏信息
  static VOID SetAllowAvertCheatMode(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_ALLOW_AVERT_CHEAT_MODE : dwServerRule &= ~SR_ALLOW_AVERT_CHEAT_MODE;
  }

  // 游戏规则
public:
  // 记录积分
  static VOID SetRecordGameScore(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_RECORD_GAME_SCORE : dwServerRule &= ~SR_RECORD_GAME_SCORE;
  }
  // 记录过程
  static VOID SetRecordGameTrack(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_RECORD_GAME_TRACK : dwServerRule &= ~SR_RECORD_GAME_TRACK;
  }
  // 动态底分
  static VOID SetDynamicCellScore(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_DYNAMIC_CELL_SCORE : dwServerRule &= ~SR_DYNAMIC_CELL_SCORE;
  }
  // 即时写分
  static VOID SetImmediateWriteScore(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_IMMEDIATE_WRITE_SCORE : dwServerRule &= ~SR_IMMEDIATE_WRITE_SCORE;
  }

  // 房间规则
public:
  // 禁止进入
  static VOID SetForbidRoomEnter(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_ROOM_ENTER : dwServerRule &= ~SR_FORBID_ROOM_ENTER;
  }
  // 禁止进入
  static VOID SetForbidGameEnter(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_GAME_ENTER : dwServerRule &= ~SR_FORBID_GAME_ENTER;
  }
  // 禁止旁观
  static VOID SetForbidGameOnlook(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_GAME_ONLOOK : dwServerRule &= ~SR_FORBID_GAME_ONLOOK;
  }

  // 银行规则
public:
  // 禁止取款
  static VOID SetForbidTakeInRoom(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_TAKE_IN_ROOM : dwServerRule &= ~SR_FORBID_TAKE_IN_ROOM;
  }
  // 禁止取款
  static VOID SetForbidTakeInGame(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_TAKE_IN_GAME : dwServerRule &= ~SR_FORBID_TAKE_IN_GAME;
  }
  // 禁止存钱
  static VOID SetForbidSaveInRoom(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_SAVE_IN_ROOM : dwServerRule &= ~SR_FORBID_SAVE_IN_ROOM;
  }
  // 禁止存钱
  static VOID SetForbidSaveInGame(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_SAVE_IN_GAME : dwServerRule &= ~SR_FORBID_SAVE_IN_GAME;
  }

  // 其他规则
public:
  // 禁止配置
  static VOID SetForbidGameRule(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_GAME_RULE : dwServerRule &= ~SR_FORBID_GAME_RULE;
  }
  // 禁止锁桌
  static VOID SetForbidLockTable(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_FORBID_LOCK_TABLE : dwServerRule &= ~SR_FORBID_LOCK_TABLE;
  }
  // 允许陪玩
  static VOID SetAllowAndroidAttend(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_ALLOW_ANDROID_ATTEND : dwServerRule &= ~SR_ALLOW_ANDROID_ATTEND;
  }
  // 允许占位
  static VOID SetAllowAndroidSimulate(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_ALLOW_ANDROID_SIMULATE : dwServerRule &= ~SR_ALLOW_ANDROID_SIMULATE;
  }

  // 支持规则
public:
  // 支持手机
  static bool IsSupportMobile(DWORD dwServerRule) { return (dwServerRule & SR_SUPPORT_TYPE_MOBILE) != 0; }
  // 支持PC
  static bool IsSupportPC(DWORD dwServerRule) { return (dwServerRule & SR_SUPPORT_TYPE_PC) != 0; }
  // 支持回放
  static bool IsSupportPlayBack(DWORD dwServerRule) { return (dwServerRule & SR_SUPPORT_PLAY_BACK) != 0; }
  // 支持手机
  static VOID SetSupportMobile(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_SUPPORT_TYPE_MOBILE : dwServerRule &= ~SR_SUPPORT_TYPE_MOBILE;
  }
  // 支持PC
  static VOID SetSupportPC(DWORD& dwServerRule, bool bEnable) { bEnable ? dwServerRule |= SR_SUPPORT_TYPE_PC : dwServerRule &= ~SR_SUPPORT_TYPE_PC; }
  // 支持回放
  static VOID SetSupportPlayBack(DWORD& dwServerRule, bool bEnable) {
    bEnable ? dwServerRule |= SR_SUPPORT_PLAY_BACK : dwServerRule &= ~SR_SUPPORT_PLAY_BACK;
  }
};

//////////////////////////////////////////////////////////////////////////////////
